{include file="public/header"}
<div class="pub_wid notice_cont">
    <div class="notice_left bgb lf" id="newsIndex">
        <h1>公告列表<span>当前位置：<a href="/">主页</a>><a href="#">公告列表</a></span></h1>
        <div class="ent_cont widthauto">
            <dl v-for="item in list">
                <a :href="'/index/notice/detail/id/'+item.id">
                    <dt><img style="width: 148px;height: 75px" :src="item.image" /></dt>
                    <dd><em class="rg">{{item.create_time}}</em><span>{{item.title}}</span></dd>
                    <dd>{{item.summary}}</dd>
                </a>
            </dl>
        </div>
        <div class="widthauto pages_box">
            <a @click="pageNumGetList(1)">首页</a>
            <a @click="pageNextList(-1)">上一页</a>
<!--            <a v-for="item in pageInfo.total" @click="pageNumGetList(item)">{{item}}</a>-->
            <a v-for="(item,index) in pageInfo.total" :class="(index+1)==current_page?'pages_box_cur':''" @click="pageNumGetList(item)">{{item}}</a>
            <a @click="pageNextList(1)">下一页</a>
            <a  @click="pageNumGetList(pageInfo.total)">尾页</a>
        </div>
    </div>
    {include file="public/right"}
</div>
{include file="public/footer"}
<script>
    var vmNewsList = new Vue({
        el:'#newsIndex',
        data:{
            current_page:1,
            num:15,
            list:[],
            pageInfo:{}
        },
        methods:{
            pageNumGetList:function(page){
                var el = this
                el.current_page = page
                el.getAllList()
            },
            pageNextList:function (num) {
                var el = this;
                var set_current_page = el.current_page*1+num
                // el.current_page = el.pageInfo.current_page*1+num
                console.log(el.current_page)
                if( set_current_page < 1){
                    $.customToastr("error","已经是第一页啦");
                    return;
                }
                if(set_current_page > el.pageInfo.total){
                    $.customToastr("error","已经是最后一页啦");
                    return;
                }
                el.current_page = set_current_page
                el.getAllList();
            },
            //条件更改无法从第一页查询，跳转方法
            changeWhereGetList:function(){
                var el = this
                el.current_page = 1
                el.getAllList()
            },
            getAllList:function () {
                var el = this;
                var paging = {
                    'current_page':el.current_page,
                    "num":el.num
                }
                var postData = {
                    'paging':paging
                }
                AjaxPost(postData,'/index/notice/getListPage').then((response)=>{
                    if(response.result.list){
                        el.list = response.result.list
                    }
                    if(response.result.pageInfo){
                        el.pageInfo = response.result.pageInfo
                    }
                    console.log(response)
                })
            }

        },
        mounted(){
            this.$nextTick(function () {
                this.getAllList()

            })
        },
        created(){


        }
    })
</script>